


	// HUSTLE

		* In phase 1 baseline, we have a different version

			gen steallast_wks_b = steallast_b if steallastunit_b==2 & p1==1
			replace steallast_wks_b = steallast_b/7 if steallastunit_b==1 & p1==1
			replace steallast_wks_b = steallast_b*4 if steallastunit_b==3 & p1==1

			gen steals_p1_b = (stealhustle_b==1 | steal_b==1 | (steallast_wks_b>0 & steallast_wks_b!=.)) if p1==1
			gen steals_felony_p1_b = (steals_p1_b==1 & stealmuggerever_b==1) if p1==1

			gen stealnb_p1_b=steal7d_b*4
			replace stealnb_p1_b=4 if steals_p1_b==1 & stealnb_p1_b==.
			replace stealnb_p1_b=0 if steals_p1_b==0 & stealnb_p1_b==.

		*  Harmonise 2w (Endline) and 4w (Baseline) into one variable
			foreach y in stealtakethings stealmistakecorr stealscrape stealpickpocket stealscam stealblackdeed stealmugger stealarmedrob {
				gen `y'_b = `y'4w_b
				gen `y'_e = `y'2w_e
				replace `y'_e=`y'4w_e/2 if `y'_e==.

				gen `y'x_b = `y'4wx_b
				gen `y'x_e = `y'2wx_e
			}

			* stealblackdeed4wx_e doesn't exist because it was not asked at p1_e3wks

			foreach y in stealtakethings stealmistakecorr stealscrape stealpickpocket stealscam stealmugger stealarmedrob stealblackdeed {
				cap replace `y'x_e=`y'4wx_e/2 if `y'x_e==.
				replace `y'x_e = 0 if missing(`y'x_e)
			}

		sum stealtakethings_b stealtakethingsx_b stealmistakecorr_b stealmistakecorrx_b stealscrape_b stealscrapex_b  stealpickpocket_b stealpickpocketx_b stealscam_b stealscamx_b  stealblackdeed_b stealblackdeedx_b stealmugger_b stealmuggerx_b  stealarmedrob_b stealarmedrobx_b


///  replace stealtakethingsx_e =.n if stealscrapex_e==-999
///  replace stealscrapex_e=.n if stealscrapex_e==-999



		foreach p in b e {

		* Variables
			sum hupeerpickpocket_`p' hupeerscam_`p' hupeermugger_`p' hupeerarmedrob_`p' stealtakethings_`p' stealtakethingsx_`p' stealmistakecorr_`p' stealmistakecorrx_`p' stealscrape_`p' stealscrapex_`p' stealpickpocket_`p' stealpickpocketx_`p' stealscam_`p' stealscamx_`p' stealblackdeed_`p' stealmugger_`p' stealmuggerx_`p' stealarmedrob_`p' stealarmedrobx_`p' stealweapon_`p' stealweaponspecify_`p' stealweaponspecifyoth_`p' stealsurvive_`p'

		* Stealing and crime indicators

			gen steals_`p' = (stealtakethings_`p' == 1 | stealmistakecorr_`p' == 1 | stealscrape_`p' == 1 | stealpickpocket_`p' == 1 | stealscam_`p' == 1 | stealblackdeed_`p' == 1 | stealmugger_`p' == 1 | stealarmedrob_`p' == 1 | stealsurvive_`p' == 1) if stealtakethings_`p'!=.
			replace steals_b=steals_p1_b if p1==1
				la var steals_`p' "Stealing: 1 if yes to any stealing questions in past 2 weeks"

			gen steals_felony_`p' = (stealmugger_`p' == 1 | stealarmedrob_`p' == 1) if steals_`p'!=.
			replace steals_felony_b=steals_felony_p1_b if p1==1
				la var steals_felony_`p' "Stealing: 1 if yes to mugging or armed robbery in past 2 weeks"

			egen stealnb_`p' = rowtotal(stealtakethingsx_`p' stealmistakecorrx_`p' stealscrapex_`p' stealpickpocketx_`p' stealscamx_`p' stealblackdeedx_`p' stealmuggerx_`p' stealarmedrobx_`p' ) if steals_`p'!=.
			replace stealnb_b=stealnb_p1_b if p1==1


***Censoring at 99th (non-zero) percentile

			gen cens_stealnb_`p' = stealnb_`p'
			qui sum cens_stealnb_`p' if cens_stealnb_`p'!= 0 & round <= 6, d
				qui replace cens_stealnb_`p' = r(p99) if cens_stealnb_`p'>r(p99) & !missing(cens_stealnb_`p') & round <= 6

*We are censoring at different levels for 1Y and 10Y to keep consistency across papers.
	            qui sum cens_stealnb_`p' if cens_stealnb_`p'!= 0, d
				qui replace cens_stealnb_`p' = r(p99) if cens_stealnb_`p'>r(p99) & !missing(cens_stealnb_`p') & round >= 7




				la var stealnb_`p'      "Stealing: Nb of stealing activities in past 2 weeks (EL) or 4 weeks (BL)"
				la var cens_stealnb_`p' "Stealing: Nb of stealing activities in past 2 weeks (EL) or 4 weeks (BL), cens. at p99"

******************************************


			egen stealnb_felony_`p' = rowtotal(stealmuggerx_`p' stealarmedrobx_`p' ) if steals_`p'!=.
				replace stealnb_felony_b=stealnb_p1_b if p1==1
				la var stealnb_felony_`p' "Stealing: Nb of felony stealing activities in past 2 weeks (EL) or 4 weeks (BL)"

			egen stealnb_nonviol_`p' = rowtotal(stealtakethingsx_`p' stealmistakecorrx_`p' stealscrapex_`p' stealpickpocketx_`p' stealscamx_`p' stealblackdeedx_`p') if steals_`p'!=.
				replace stealnb_nonviol_b=stealnb_p1_b if p1==1
				la var stealnb_nonviol_`p' "Stealing: Nb of non-violent stealing activities in past 2 weeks (EL) or 4 weeks (BL)"

			bysort phase round: summ steals_`p' steals_felony_`p' stealnb_`p'

			* Create version of stealing count usings only high/low emphasis components
			egen stealnb_g1_`p' = rowtotal(stealtakethingsx_`p' stealmistakecorrx_`p' stealscrapex_`p' stealpickpocketx_`p' stealscamx_`p' stealblackdeedx_`p' stealmuggerx_`p' stealarmedrobx_`p' ) if steals_`p'!=.
				replace stealnb_g1_`p'=stealnb_p1_b if p1==1
				la var stealnb_g1_`p' "Number of stealing activities, emphasis greater than 1"
			gen stealnb_le1_`p' = .
				replace stealnb_le1_`p'=stealnb_p1_b if p1==1
				la var stealnb_le1_`p' "Number of stealing activities, emphasis less than or equal to 1"

			egen stealnb_g15_`p' = rowtotal(stealtakethingsx_`p' stealmistakecorrx_`p' stealscrapex_`p' stealpickpocketx_`p' stealscamx_`p' stealblackdeedx_`p' stealmuggerx_`p' stealarmedrobx_`p' ) if steals_`p'!=.
				replace stealnb_g15_`p'=stealnb_p1_b if p1==1
				la var stealnb_g15_`p' "Number of stealing activities, emphasis greater than 1.5"
			gen stealnb_le15_`p' = .
				replace stealnb_le15_`p'=stealnb_p1_b if p1==1
				la var stealnb_le15_`p' "Number of stealing activities, emphasis less than or equal to 1.5"

			egen stealnb_g2_`p' = rowtotal(stealtakethingsx_`p' stealblackdeedx_`p' stealmuggerx_`p') if steals_`p'!=.
				replace stealnb_g2_`p'=stealnb_p1_b if p1==1
				la var stealnb_g2_`p' "Number of stealing activities, emphasis greater than 2"
			egen stealnb_le2_`p' = rowtotal(stealmistakecorrx_`p' stealscrapex_`p' stealpickpocketx_`p' stealscamx_`p' stealarmedrobx_`p'), m
				replace stealnb_le2_`p'=stealnb_p1_b if p1==1
				la var stealnb_le2_`p' "Number of stealing activities, emphasis less than or equal to 2"

		}

	// Rescale Baseline Steal NB Components
			sum stealnb_nonviol_b if p1 != 1
			local nonviol = r(mean)

			sum stealnb_felony_b if p1 != 1
			local felony = r(mean)

			qui sum stealnb_b if p1 != 1
			local total = r(mean)

			local ratio_n = `total'/`nonviol'
			local ratio_f = `total'/`felony'

			replace stealnb_nonviol_b = stealnb_b/ `ratio_n' if p1 == 1
			replace stealnb_felony_b = stealnb_b / `ratio_f' if p1 == 1


	// Number of drug sales
		qui replace drugsell2wx_e = 0 if missing(drugsell2wx_e) & (round == 5 | round == 6) & !missing(stealnb_e)

	// Number of crimes
		qui egen crimes2wx_e = rowtotal(stealnb_e drugsell2wx_e), missing
			la var crimes2wx_e "Number of thefts and drug deals in past 2 weeks"


	// FIGHTS, DISPUTES AND ARRESTS

		* Phase 1 Baseline had a different version. We populate phase 2 variables with phase 1's
			replace fightsmlneigh4w_b=palneigh_b/6 if p1==1
			replace fightphys4w_b=fights_b/6 if p1==1
			replace fightweapon4w_b=weapons_b/6 if p1==1
			replace fightweapon4w_b=0 if fightweapon4w_b==. & p1==1

		* Special case: Leaders and police
			* (A) In some survey we asked 1 question: (p1_e3wks p1_e5m)
				* fightsmllead2w In the last 2 weeks up to now, how many small small palavas you have with a local leader or police?

			* (B) In some survey we asked 2 questions: (p2_e2wks p2_e2w2w p1_e7m p1_e12m p3_e2w p3_e5w)
				* fightsmlleader2w In the last 2 weeks up to now, how many small small palavas you have with a local leader?
				* fightsmlpolice2w In the last 2 weeks up to now, how many small small palavas you have with the police?

			* We want to keep them separated so we populate the second version with the first version.

			* Baseline (4w)

				* P1 BL we have only pallead In the past 6 months, how many palavas have you had with a local leader or police?

					replace fightsmlleader4w_b = pallead_b/6*4 if p1==1
					replace fightsmlpolice4w_b = pallead_b/6*4 if p1==1
					replace fightbigleader4w_b = pallead_b/6*4 if p1==1
					replace fightbigpolice4w_b = pallead_b/6*4 if p1==1

				* P2 BL we have
					* fightsmllead4w_b  	In the last four weeks up to now, how many small small palavas you have with a local leader or police?
					* fightbiglead4w_b	In the last four weeks up to now, how many big palavas you have with a local leader or police?

					replace fightsmlleader4w_b = fightsmllead4w_b/2 if p2==1
					replace fightsmlpolice4w_b = fightsmllead4w_b/2 if p2==1
					replace fightbigleader4w_b = fightbiglead4w_b/2 if p2==1
					replace fightbigpolice4w_b = fightbiglead4w_b/2 if p2==1

				* P3 BL, we have the correct version fightsmlleader4w_b fightsmlpolice4w_b fightbigleader4w_b fightbigpolice4w_b

			* Endline (2w)

				* P1 5m we have
					* fightsmllead2w	In the last 2 weeks up to now, how many small small palavas you have with a local leader or police?
					* fightbiglead2w	In the last 2 weeks up to now, how many big palavas you have with a local leader or police?

				replace fightsmlleader2w_e = fightsmllead2w_e/2 if p1_e5m==1
				replace fightsmlpolice2w_e = fightsmllead2w_e/2 if p1_e5m==1
				replace fightbigleader2w_e = fightbiglead2w_e/2 if p1_e5m==1
				replace fightbigpolice2w_e = fightbiglead2w_e/2 if p1_e5m==1


				* P1 3wks we have
					* fightsmllead4w	In the last four weeks up to now, how many small small palavas you have with a local leader or police?
					* fightbiglead4w	In the last four weeks up to now, how many big palavas you have with a local leader or police?

				replace fightsmlleader2w_e = fightsmllead4w_e/2*2 if p1_e3wks==1
				replace fightsmlpolice2w_e = fightsmllead4w_e/2*2 if p1_e3wks==1
				replace fightbigleader2w_e = fightbiglead4w_e/2*2 if p1_e3wks==1
				replace fightbigpolice2w_e = fightbiglead4w_e/2*2 if p1_e3wks==1

				* p2_e2wks p2_e2w2w, p1_e7m, p1_e12m, p1_e13m, p3_e2w, p3_e5w we have the correct version


			* Harmonize 2w and 4w at EL
				* p1_e3wks we ask about 4w and the rest we ask about 2w
				destring fine2w_e, force replace

				foreach y in fightsmlneigh fightbigneigh fightphys fightweapon fine policestation  {
					replace `y'2w_e = `y'4w_e/2 if p1_e3wks==1
				}

			* Harmonize BL(4w) and EL (2w)

				foreach y in fightsmlleader fightbigleader fightsmlpolice fightbigpolice fightsmlneigh fightbigneigh fightphys fightweapon fine policestation  {
					gen `y'_e = `y'2w_e
					gen `y'_b = `y'4w_b
				}

				gen policejail_e = policejail2w_e

			* Policejail is not in the baseline survey. We generate empty variable
				* At endline we ask about policejail2w at p1_e7m, p1_e12m, p1_e13m p2_e2wks p2_e2w2w, p3_e2w p3_e5w
				* At endline we ask about policejail3m at p1_e7m, p1_e12m, p1_e13m

				gen policejail_b=.
				gen policejail3m_b=.

			* Policestation3m is not in the baseline survey. We generate empty variable
				gen policestation3m_b=.

	foreach p in b e {

		* Arrested since last survey
			egen policestation2_`p'=	rowtotal (policestation_`p' policestation3m_`p'), m
			egen policejail2_`p'= rowtotal(policejail_`p' policejail3m_`p'), m

		* Variables
			sum fightsmlleader_`p' fightbigleader_`p' fightsmlpolice_`p' fightbigpolice_`p' fightsmlneigh_`p' fightbigneigh_`p' fightphys_`p' fightweapon_`p'  fine_`p' policestation_`p' policestation2_`p' policejail_`p' policejail2_`p'

		* Indicators
			foreach x of varlist fightsmlneigh_`p' fightbigneigh_`p' fightphys_`p' fightweapon_`p' fightsmlleader_`p' fightbigleader_`p' fightsmlpolice_`p' fightbigpolice_`p' fine_`p' policestation_`p' policestation2_`p' policejail_`p' policejail2_`p' {
				gen any_`x' = (`x'!=0) if `x'!=.
					la var any_`x' "Indicator for `x'"
			}

		* All disputes total
			egen disputes_all_`p' = rowtotal(fightsmlneigh_`p' fightbigneigh_`p' fightphys_`p' fightweapon_`p' fightsmlleader_`p' fightbigleader_`p' fightsmlpolice_`p' fightbigpolice_`p' fine_`p'), mi
			qui sum disputes_all_`p'
				la var disputes_all_`p' "Index of all disputes and fights in the past 2 weeks"


			qui gen disputes_all_z_`p' = (disputes_all_`p'-r(mean))/r(sd)
				la var disputes_all_z_`p' "Index of all disputes and fights in the past 2 weeks, Z"


***Censoring at 99th (non-zero) percentile

if ("`p'" == "b") {

		gen cens_disputes_all_`p'   = disputes_all_`p'
	qui sum disputes_all_`p' if disputes_all_`p'!= 0, d
	qui replace cens_disputes_all_`p'   = r(p99) if disputes_all_`p' > r(p99) & !missing(disputes_all_`p')



			qui sum cens_disputes_all_`p'
				qui gen cens_disputes_all_z_`p' = (cens_disputes_all_`p'-r(mean))/r(sd)
				la var cens_disputes_all_z_`p' "Index of all disputes and fights in the past 2 weeks, Z"


}

*With all the censoring and standarization we need to be careful
*since it means sightly different thigns if we add data, changing previous results.

*We will do these things in 3 ways:
*a) pooled is just take all the data we have and standarize based on that. Thus we pool R1-R8
*b) split r78 is to assume that 10Y is different than 1Y and before. Thus we pool R1-6 and pool R7-8
*c) known so far is to standarize based on the known distribution at the moment. Thus we pool R1-6, and R1-R8 for the last 2 rounds.


if ("`p'" == "e") {

			gen cens_disputes_all_ss_`p'   = disputes_all_`p'
			gen cens_disputes_all_p_`p'   = disputes_all_`p'
			gen cens_disputes_all_k_`p'   = disputes_all_`p'


			qui sum disputes_all_`p' if disputes_all_`p'!= 0 & round <= 6, d
				qui replace cens_disputes_all_ss_`p' = r(p99) if disputes_all_`p'>r(p99) & !missing(disputes_all_`p') & round <= 6
				qui replace cens_disputes_all_k_`p' =  r(p99) if disputes_all_`p'>r(p99) & !missing(disputes_all_`p') & round <= 6


			qui sum disputes_all_`p' if disputes_all_`p'!= 0 & round >= 7, d
				qui replace cens_disputes_all_ss_`p' = r(p99) if disputes_all_`p'>r(p99) & !missing(disputes_all_`p') & round >= 7


			qui sum disputes_all_`p' if disputes_all_`p'!= 0, d
				 qui replace cens_disputes_all_k_`p' =  r(p99) if disputes_all_`p'>r(p99) & !missing(disputes_all_`p') & round >=7
				 qui replace cens_disputes_all_p_`p'  =  r(p99) if disputes_all_`p'>r(p99) & !missing(disputes_all_`p')


				la var cens_disputes_all_p_`p'   "Index of all disputes and fights in the past 2 weeks, cens. at p99"
				la var cens_disputes_all_ss_`p' "Index of all disputes and fights in the past 2 weeks, cens. at p99"
				la var cens_disputes_all_k_`p'  "Index of all disputes and fights in the past 2 weeks, cens. at p99"

****Z-version of censored version. (This is the one that was used traditionally.)


			gen cens_disputes_all_z_p_`p'   = .
			gen cens_disputes_all_z_ss_`p'   = .
			gen cens_disputes_all_z_k_`p'   = .


			qui sum cens_disputes_all_p_`p' , d
			qui replace cens_disputes_all_z_p_`p' = (cens_disputes_all_p_`p'-r(mean))/r(sd)



			qui sum cens_disputes_all_ss_`p' if round <= 6 , d
			qui replace cens_disputes_all_z_ss_`p' = (cens_disputes_all_ss_`p'-r(mean))/r(sd) if round <= 6

			qui sum cens_disputes_all_ss_`p' if round >=7 , d
			qui replace cens_disputes_all_z_ss_`p' = (cens_disputes_all_ss_`p'-r(mean))/r(sd) if round >= 7



			qui sum cens_disputes_all_k_`p' if round <= 6 , d
			qui replace cens_disputes_all_z_k_`p' = (cens_disputes_all_k_`p'-r(mean))/r(sd) if round <= 6

			qui sum cens_disputes_all_k_`p'  , d
			qui replace cens_disputes_all_z_k_`p' = (cens_disputes_all_k_`p'-r(mean))/r(sd) if round >= 7


				la var cens_disputes_all_z_p_`p'   "Index of all disputes and fights in the past 2 weeks cens., Z"
				la var cens_disputes_all_z_ss_`p' "Index of all disputes and fights in the past 2 weeks cens., Z"
				la var cens_disputes_all_z_k_`p'  "Index of all disputes and fights in the past 2 weeks cens., Z"

				}
******************************************

			egen disputes_serious_all_`p' = rowtotal(fightbigneigh_`p' fightweapon_`p' fightbigleader_`p' fightbigpolice_`p' fine_`p'), mi
				qui sum disputes_serious_all_`p' if disputes_serious_all_`p'!= 0, d
				qui replace disputes_serious_all_`p' = r(p99) if disputes_serious_all_`p'>r(p99) & !missing(disputes_serious_all_`p')
				la var disputes_serious_all_`p' "Index of all serious disputes and fights in the past 2 weeks"

			gen any_dispute_`p' = (disputes_all_`p' !=0) if disputes_all_`p' !=.
				la var any_dispute_`p' "Indicator for any dispute or armed fight in past two weeks"

			gen any_serious_dispute_`p' = (disputes_serious_all_`p' !=0) if disputes_serious_all_`p' !=.
				la var any_serious_dispute_`p' "Indicator for any serious dispute or armed fight in past two weeks"

			bysort phase round: summ fightsmlneigh_`p' fightbigneigh_`p' fightphys_`p' fightweapon_`p' fightsmlleader_`p' fightbigleader_`p' fightsmlpolice_`p' fightbigpolice_`p' fine_`p' policestation_`p' policestation2_`p' policejail_`p' policejail2_`p' any_*_`p' disputes_*_`p'

		* Dummy for arrested/jail

			gen arrested_`p' = (policestation2_`p' >0 & policestation2_`p'!=.) | (policejail2_`p'>0 & policejail2_`p'!=.) if policestation2_`p' !=.
				la var arrested_`p' "Arrested by the police or in jail"

		* Version of "serious disputes" with only high/low emphasis components
			egen disputes_g1_`p' = rowtotal(fightbigneigh_`p' fightweapon_`p' fightbigpolice_`p'), mi
				qui sum disputes_g1_`p' if disputes_g1_`p'!= 0, d
				qui replace disputes_g1_`p' = r(p99) if disputes_g1_`p'>r(p99) & !missing(disputes_g1_`p')
				la var disputes_g1_`p' "Index of all serious disputes, emphasis greater than 1"

			egen disputes_le1_`p' = rowtotal(fightbigleader_`p' fine_`p'), mi
				qui sum disputes_le1_`p' if disputes_le1_`p'!= 0, d
				qui replace disputes_le1_`p' = r(p99) if disputes_le1_`p'>r(p99) & !missing(disputes_le1_`p')
				la var disputes_le1_`p' "Index of all serious disputes, emphasis less than or equal to 1"

			egen disputes_g15_`p' = rowtotal(fightweapon_`p' fightbigpolice_`p'), mi
				qui sum disputes_g15_`p' if disputes_g15_`p'!= 0, d
				qui replace disputes_g15_`p' = r(p99) if disputes_g15_`p'>r(p99) & !missing(disputes_g15_`p')
				la var disputes_g15_`p' "Index of all serious disputes, emphasis greater than 1.5"

			egen disputes_le15_`p' = rowtotal(fightbigneigh_`p' fightbigleader_`p' fine_`p'), mi
				qui sum disputes_le15_`p' if disputes_le15_`p'!= 0, d
				qui replace disputes_le15_`p' = r(p99) if disputes_le15_`p'>r(p99) & !missing(disputes_le15_`p')
				la var disputes_le15_`p' "Index of all serious disputes, emphasis less than or equal to 1.5"

			egen disputes_g2_`p' = rowtotal(fightweapon_`p' fightbigpolice_`p'), mi
				qui sum disputes_g2_`p' if disputes_g2_`p'!= 0, d
				qui replace disputes_g2_`p' = r(p99) if disputes_g2_`p'>r(p99) & !missing(disputes_g2_`p')
				la var disputes_g2_`p' "Index of all serious disputes, emphasis greater than 2"

			egen disputes_le2_`p' = rowtotal(fightbigneigh_`p' fightbigleader_`p' fine_`p'), mi
				qui sum disputes_le2_`p' if disputes_le2_`p'!= 0, d
				qui replace disputes_le2_`p' = r(p99) if disputes_le2_`p'>r(p99) & !missing(disputes_le2_`p')
				la var disputes_le2_`p' "Index of all serious disputes, emphasis less than or equal to 2"



		* Version of "arrested" with only high/low emphasis components
			gen arrested_g1_`p' = (policestation2_`p' >0 & policestation2_`p'!=.) | (policejail2_`p'>0 & policejail2_`p'!=.) if policestation2_`p' !=.
				la var arrested_g1_`p' "Arrested by the police or in jail, emphasis greater than 1"
			gen arrested_le1_`p' = .
				la var arrested_le1_`p' "Arrested by the police or in jail, emphasis less than or equal to 1"

			gen arrested_g15_`p' = (policestation2_`p' >0 & policestation2_`p'!=.) | (policejail2_`p'>0 & policejail2_`p'!=.) if policestation2_`p' !=.
				la var arrested_g15_`p' "Arrested by the police or in jail, emphasis greater than 1.5"
			gen arrested_le15_`p' = .
				la var arrested_le15_`p' "Arrested by the police or in jail, emphasis less than or equal to 1.5"

			gen arrested_g2_`p' = (policestation2_`p' >0 & policestation2_`p'!=.) if policestation2_`p' !=.
				la var arrested_g2_`p' "Arrested by the police or in jail, emphasis greater than 2"
			gen arrested_le2_`p' = (policejail2_`p'>0 & policejail2_`p'!=.) if policestation2_`p' !=.
				la var arrested_le2_`p' "Arrested by the police or in jail, emphasis less than or equal to 2"

	}





* labels
		foreach p in b e {

			la var stealtakethingsx_`p'  "Hustle: hu009. In the last 4 weeks, have you taken something from behind someone that not for you?"
			la var stealmistakecorrx_`p' "Hustle: hu011. In the last 4 weeks, have you corrected someone's mistake?"
			la var stealscrapex_`p' "Hustle: hu013. In the last 4 weeks, have you cheated or scraped from people?"
			la var stealpickpocketx_`p' "Hustle : hu015. In the last 4 weeks, have you done any  pickpocketing?"
			la var stealscamx_`p' "Hustle : hu017. In the last 4 weeks , have you done duping or 419 ?"
			la var stealblackdeedx_`p' "Hustle: hu019. In the last 4 weeks, have you done black deed business?"
			la var stealmuggerx_`p' "Hustle: hu020. In the last 4 weeks, have you jumped on somebody to take their things?"
			la var stealarmedrobx_`p' "Hustle: hu022. In the last 4 weeks, have you done any armed robbery?"
			la var fightsmlneigh_`p'  "Comm: cy003. In the last four weeks up to now, how many small small palavas you have with a neighbor?"
			la var fightbigneigh_`p'  "Comm: cy004. In the last four weeks up to now, how many big palavas you have with a neighbor?"
			la var fightphys_`p' "Comm: cy005. In the last four weeks up to now, how many physical fights were you involved in?"
			la var fightweapon_`p'  "Comm: cy006. How many of these fights involved weapons?"
			la var fightsmlleader_`p'  "Comm: cy025 In the last 2 weeks up to now, how many small small palavas you have with a local leader or police?"
			la var fightbigleader_`p'  "Comm: cy026 In the last 2 weeks up to now, how many big palavas you have with a local leader or police?"
			la var fightsmlpolice_`p' "Comm: In the last 2 weeks up to now, how many small small palavas you have with the police?"
			la var fightbigpolice_`p' "Comm: In the last 2 weeks up to now, how many big palavas you have with the police?"
			la var fine_`p' "Comm: cy012. In the last four weeks up to now,  you ever get fined money or some other thing for doing something bad in the community?"
		}




		foreach x of varlist  fightsmlleader2w_e fightsmlpolice2w_e fightsmlneigh2w_e fightsmlleader_e fightsmlpolice_e fightsmlneigh_e stealtakethingsx_e  stealscrapex_e  ///
		     disputes_g2_e disputes_le1_e disputes_g15_e {
			replace `x'=.n if `x'==-999
		}



// DOMESTIC VIOLENCE

		foreach v in maccuse mthreat minsult mhit {
			local lab: var lab `v'_e
			gen `v'_resc_e = `v'_e * (-1) + 4
			la var `v'_resc_e "`lab' (0-3) ADD BAD"
		}

		egen domabuse_e = rowtotal(maccuse_resc_e mthreat_resc_e minsult_resc_e mhit_resc_e), m
			la var domabuse_e "Index of domestic verbal abuse (0-12)"


			gen domabuse_z_p_e   = .
			gen domabuse_z_ss_e = .
			gen domabuse_z_k_e  = .


			qui sum domabuse_e , d
			qui replace domabuse_z_p_e  = (domabuse_e - r(mean)) / r(sd)
			qui replace domabuse_z_k_e  = (domabuse_e - r(mean)) / r(sd) if round >= 7


			qui sum domabuse_e if round <= 6 , d
			qui replace domabuse_z_ss_e  = (domabuse_e - r(mean)) / r(sd) if round <= 6
			qui replace domabuse_z_k_e  = (domabuse_e - r(mean)) / r(sd) if round <= 6


			qui sum domabuse_e if round >=7 , d
			qui replace domabuse_z_ss_e = (domabuse_e - r(mean)) / r(sd) if round >= 7


    		local label: var label domabuse_e

				la var domabuse_z_p_e   "Z: `label'"
				la var domabuse_z_ss_e "Z: `label'"
				la var domabuse_z_k_e  "Z: `label'"




		egen verbalabuse_e = rowtotal (maccuse_resc_e mthreat_resc_e minsult_resc_e), m
			la var verbalabuse_e "Index of domestic verbal abuse (0-9)"

		foreach v in maccuse mthreat minsult mhit {
			local lab: var lab `v'_e
			gen `v'_dum1_e = (`v'_resc_e >= 1) if !missing(`v'_resc_e)
				la var `v'_dum1_e "At least rarely: `lab'"
			gen `v'_dum2_e = (`v'_resc_e >= 2) if !missing(`v'_resc_e)
				la var `v'_dum2_e "At least sometimes: `lab'"
		}

		egen verbalabuse_dum1_e = rowtotal (maccuse_dum1_e mthreat_dum1_e minsult_dum1_e), m
			la var verbalabuse_dum1_e "Index of domestic verbal abuse (0-3), based on dum1s"
		egen verbalabuse_dum2_e = rowtotal (maccuse_dum2_e mthreat_dum2_e minsult_dum2_e), m
			la var verbalabuse_dum2_e "Index of domestic verbal abuse (0-3), based on dum2s"



	// DRUGS DEALING

		foreach p in b e {

			gen drugssellever_`p' = (drugsellself_`p'==1 | drugsell4w_`p'==1 | drugsell2w_`p'==1)
			replace drugssellever_`p'=. if drugsellself_`p'==. & drugsell4w_`p'==. & drugsell2w_`p'==.
				la var drugssellever_`p' "Indicator for usually Sells drugs"

		}





	// COMMUNITY VIOLENCE (p1_e7m, p1_e13m, p2_e2w2w, p3_e5w)

		* All variables
			sum cvtalkdemstpc_e cvseedemstpc6m_e cvjoindemstpc6m_e cvhypdemstpc_e cvtalkdemstvi_e cvseedemstvi6m_e cvjoindemstvi6m_e cvhypdemstvi_e cvtalkvjrogue_e cvseevjrogue6m_e cvjoinvjrogue6m_e cvhypvjrogue_e cvtalkvjviolator_e cvseevjviolator6m_e cvjoinvjviolator6m_e cvhypvjviolator_e cvtalkvjgroup_e cvseevjgroup6m_e cvjoinvjgroup6m_e cvhypvjgroup_e

		* rescale talking variables
		foreach v in demstpc demstvi vjrogue vjviolator vjgroup {
			local lab: var lab cvtalk`v'_e
			gen cvtalk`v'_resc_e = cvtalk`v'_e -1
			la var cvtalk`v'_resc_e "`lab'"
		}
		* Variables in the indes
			sum cvjoindemstpc6m_e  cvhypdemstpc_e cvjoindemstvi6m_e cvhypdemstvi_e cvjoinvjrogue6m_e cvhypvjrogue_e cvjoinvjviolator6m_e cvhypvjviolator_e cvjoinvjgroup6m_e cvhypvjgroup_e

		* Impute 0 for joining if did not have the opportunity

		foreach x in demstpc6m_e demstvi6m_e vjrogue6m_e vjviolator6m_e vjgroup6m_e {
			replace cvjoin`x' = 0 if cvjoin`x' == . & cvsee`x'==0
		}

		* Indexes
			egen communityviolence_e = rowtotal (cvjoindemstpc6m_e  cvhypdemstpc_e cvjoindemstvi6m_e cvhypdemstvi_e cvjoinvjrogue6m_e cvhypvjrogue_e cvjoinvjviolator6m_e cvhypvjviolator_e cvjoinvjgroup6m_e cvhypvjgroup_e) if p1_e7m==1 | p2_e2w2w==1 |p1_e13m==1 |p3_e5w==1, missing
				la var communityviolence_e "Community Violence Index"

			gen communityviolencedum_e = (communityviolence_e!=0) if p1_e7m==1 | p2_e2w2w==1 | p1_e13m==1 |p3_e5w==1
				la var communityviolencedum_e "Community Violence Dummy"

			egen commvioltalk_e = rowtotal (cvtalkdemstvi_resc_e cvtalkvjrogue_resc_e cvtalkvjviolator_resc_e cvtalkvjgroup_resc_e) if p1_e7m==1 | p2_e2w2w==1 |p1_e13m==1 |p3_e5w==1| p2_e13m == 1| p3_e13m == 1 |p1_e9y==1 |p2_e9y==1 |p3_e9y==1 |p1_e10y==1 |p2_e10y==1 |p3_e10y==1, missing
				la var commvioltalk_e "Talking about community violence index"
			egen commviolsee_e = rowtotal (cvseedemstvi6m_e cvseevjrogue6m_e cvseevjviolator6m_e cvseevjgroup6m_e) if p1_e7m==1 | p2_e2w2w==1 |p1_e13m==1 |p3_e5w==1| p2_e13m == 1| p3_e13m == 1 |p1_e9y==1 |p2_e9y==1 |p3_e9y==1 |p1_e10y==1 |p2_e10y==1 |p3_e10y==1 , missing
				la var commviolsee_e "Awareness about community violence index"
			egen commvioljoin_e = rowtotal (cvjoindemstvi6m_e cvjoinvjrogue6m_e cvjoinvjviolator6m_e cvjoinvjgroup6m_e) if p1_e7m==1 | p2_e2w2w==1 |p1_e13m==1 |p3_e5w==1| p2_e13m == 1| p3_e13m == 1 |p1_e9y==1 |p2_e9y==1 |p3_e9y==1 |p1_e10y==1 |p2_e10y==1 |p3_e10y==1 , missing
				la var commvioljoin_e "Participation in community violence index"
			egen commviolhyp_e = rowtotal (cvhypdemstvi_e cvhypvjrogue_e cvhypvjviolator_e cvhypvjgroup_e) if p1_e7m==1 | p2_e2w2w==1 |p1_e13m==1 |p3_e5w==1| p2_e13m == 1| p3_e13m == 1 |p1_e9y==1 |p2_e9y==1 |p3_e9y==1 |p1_e10y==1 |p2_e10y==1 |p3_e10y==1 , missing
				la var commviolhyp_e "Hypothetical participation in community violence index"
